<?php
namespace App\Pay\Gateway\Wechat;

class MpGateway extends Gateway
{
    public function pay($payload)
    {
        $payload['trade_type'] = $this->getTradeType();
        $requestData = [
            'appId' => $payload['appid'] ?? '',
            'timeStamp' => time(),
            'nonceStr' => md5(uniqid()),
            'package' => 'prepay_id=' . $this->requestOrder($payload)->get('prepay_id'),
            'signType' => 'MD5',
        ];
        $requestData['paySign'] = Request::sign($requestData);
        return $requestData;
    }

    protected function getTradeType(): string
    {
        return 'JSAPI';
    }
}
